/*
    通过审核
 */
$(function () {
    let userId = getQueryString("userId");
    let url = '../audit/list-pass';
    if (userId) {
        url += '?userId=' + userId;
    }
    $("#jqGrid").Grid({
        url: url,
        colModel: [
            {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
            {label: '用户编号', name: 'userId', index: 'userId', width: 20},
            {label: '真实姓名', name: 'name', index: 'name', width: 30},
            {
                label: '证件类型', name: 'type', index: 'type', width: 20, formatter: function (value) {
                    return '身份证';
                }
            },
            {label: '证件号', name: 'idCardNo', index: 'idCardNo', width: 30},
            {
                label: '正面图', name: 'frontImg', index: 'frontImg', width: 60, formatter: function (value) {
                    return transImg(value);
                }
            },
            {
                label: '反面图', name: 'reverseImg', index: 'reverseImg', width: 60, formatter: function (value) {
                    return transImg(value);
                }
            },
            {
                label: '审核状态', name: 'statu', index: 'statu', width: 20, formatter: function (value) {
                    return '<span class="label label-success">审核通过</span>';
                }
            },
            {
                label: '审核日期', name: 'createDate', index: 'createDate', width: 60, formatter: function (value) {
                    return transDate(value, "yyyy-MM-dd hh:mm:ss")
                }
            }

        ]
    });
});

var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        audit: {},
        q: {
            name: '',
            uid: ''
        }
    },
    methods: {
        query: function () {
            vm.reload();
        },

        update: function (event) {
            var id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            vm.showList = false;
            vm.title = "查看";

            vm.getInfo(id)
        },
        del: function (event) {
            var ids = getSelectedRows("#jqGrid");
            if (ids == null) {
                return;
            }
            confirm('确定要删除选中的记录？', function () {
                Ajax.request({
                    type: "POST",
                    url: "../audit/pass/delete",
                    contentType: "application/json",
                    params: JSON.stringify(ids),
                    successCallback: function (r) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    }
                });
            });
        },
        getInfo: function (id) {
            Ajax.request({
                url: "../audit/info-pass/" + id,
                async: true,
                successCallback: function (r) {
                    vm.audit = r.audit;
                }
            });
        },
        eyeImageFront: function () {
            var url = vm.audit.frontImg;
            eyeImage(url);
        },
        eyeImageReverse: function () {
            var url = vm.audit.reverseImg;
            eyeImage(url);
        },
        reload: function (event) {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'name': vm.q.name,'uid':vm.q.uid},
                page: page
            }).trigger("reloadGrid");
        },
        reloadSearch: function() {
            vm.q = {
                name: '',
                uid: ''
            }
            vm.reload();
        }
    }
});